package com.koron.operation.dispatch.bean.dto;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.koron.operation.dispatch.bean.TabPmpMonitor;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;
import java.util.List;

@Data
public class UnitSynDto {

    @ApiModelProperty(value="设备ID")
    private String equipmentId;

    @ApiModelProperty(value="设备名称")
    private String equipmentName;

    @ApiModelProperty(value="设备管理单位ID")
    private String deptManage;

    @ApiModelProperty(value="设备管理单位名称")
    private String deptManageName;

    @ApiModelProperty(value = "监控数据dpName")
    private String dpName;

    @ApiModelProperty(value = "最后同步时间")
    private String lastSynTime;

    @ApiModelProperty(value = "EAM系统最后获取同步时间")
    private Date operateTime;

    @ApiModelProperty(value = "监控数据标识")
    private String dbs;

    @ApiModelProperty(value = "监控数据库记录")
    private List<TabPmpMonitor> recordlist;

    public UnitSynDto() {
    }

    public UnitSynDto(String dpName, String lastSynTime, String dbs) {
        this.dpName = dpName;
        this.lastSynTime = lastSynTime;
        this.dbs = dbs;
    }

    // eam系统时间 转换 监控数据库时间
    public void convenTime(){
        //向后偏移一秒中  因为两边的时间个是格式不一样， 监控数据库是精确到毫秒， eam 只是精确到 秒
        if(this.operateTime != null){
            DateTime dateTime = DateUtil.offsetMinute(this.operateTime, 1);
            this.lastSynTime = DateUtil.format(dateTime, "yyyy.MM.dd HH:mm:ss");
        }
        return;
    }
}
